<?php
/**
 * Created by PhpStorm.
 * User: zhangligang
 * Date: 17/5/8
 * Time: 下午1:25
 */

namespace App\Http\Presenter;


use App\Http\Models\Goods;
use Illuminate\Support\Collection;

class GoodsPresenter implements Presenter
{

    /**
     *
     */
    public function __construct()
    {
        //
    }

    /**
     * 格式化商品列表
     * @param Collection $goodsList
     * @return array
     */
    public function formatGoodsList(Collection $goodsList)
    {

        $results = [];

        foreach ($goodsList as $goods) {

            $results[] = $this->formatGoods($goods);
        }

        return $results;

    }

    /**
     * 格式化订单
     * @param Goods $goods
     * @return array
     */
    public function formatGoods(Goods $goods)
    {

        if (!$goods) return [];

        return [

            'id' => $goods->id

        ];

    }

}